home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <winb.h>
- #include <te.h>
- #include <fntb.h>
- #include <gui.h>
- #include <egb.h>
- #include <guidbg.h>
-
- char *guiEgbPtr ; /* EGB のワークアドレス */
-
- #define MinMem (1024*20) /* 必要とする動作メモリの定義 */
-
- char *guiEgbPtr ;
-
- /* exitFunc関数の復帰値 */
- int exitFuncRet = ILLEGAL_FUNCTION ;
-
- /* alertMemFunc関数の追い越し禁止フラグ */
- static int alertMemFlag = FALSE ;
-
- /* アラートメッセージ */
- static char *alertStrMem[] =
- {"Point:\nメモリが不足しています", "確認"};
-
- /****************************************************************/
- /* メモリ不足時のアラート関数(イベント登録関数) */
- /****************************************************************/
- void alertMemFunc()
- {
- /* メモリ不足のアラート表示 */
- MMI_CallMessage(MMI_GetApliId(), GM_ALERT,
- AM_ALERT1 | AM_ALERTB0E,(int)alertStrMem) ;
-
- /* alertMemFunc関数の追い越し禁止解除 */
- alertMemFlag = FALSE ;
- }
-
- int userFunc(apliId, messId, info, data)
- int apliId;
- int messId;
- int info;
- int data;
- {
- register int ret;
-
- ret = ILLEGAL_FUNCTION;
-
- switch(messId)
- {
- /* 他のアプリから制御がきた */
- case GM_WAKE :
- {
- EVENT ev ;
-
- /* alertMemFunc関数の追い越し禁止判定 */
- if(alertMemFlag != FALSE)
- break ;
-
- /* 動作メモリのチェック */
- if(TL_checkMemory(1) * 4096 < MinMem)
- {
- /* alertMemFunc関数の追い越し禁止 */
- alertMemFlag = TRUE ;
-
- /* メモリ不足の場合はアラート処理関数をイベント登録する */
- MMI_FlushEvnt() ;
- ev.what = EVEXEC ;
- ev.shift = 0 ;
- ev.info = (int)alertMemFunc ;
- MMI_SetEvnt(&ev) ;
- break ;
- }
- break ;
- }
-
- /* 他のアプリに制御を移す */
- case GM_SLEEP :
- break ;
-
- case GM_QUIT :
- MMI_SetHaltFlag(TRUE);
- ret = NOERR ;
- break;
- }
-
- return(ret);
- }
-
- void main( argc, argv )
-
- int argc ;
- char *argv[] ;
- {
- MMICTRL ctrl ;
-
- ctrl.page0 = SCREEN16 ; /* 16色1画面に設定する */
- ctrl.page1 = SCREENUNUSED ; /* 裏画面は使用しない */
- ctrl.writePage = 0 ; /* page0 を書き込みページ */
- ctrl.displayPage = 1 ; /* 1画面表示 */
- ctrl.priority = 0 ;
- ctrl.mode = SCREENAVAILABLE ; /* 解像度無依存 */
- ctrl.width = SCREENEXPAND ; /* 解像度無依存拡張指定 */
- ctrl.size = 0 ; /* メモリの初期化は */
- ctrl.ptr = NULL ; /* GUIライブラリに任せる */
- ctrl.asize = 0 ; /* アプリケーションで必要とする */
- ctrl.aptr = NULL ; /* 初期メモリは無し */
- ctrl.move.lupx = -16384 ; /* 移動枠は */
- ctrl.move.lupy = 22 ; /* (-16384,22)- */
- ctrl.move.rdwx = 16383 ; /* (16383,16383) */
- ctrl.move.rdwy = 16383 ;
- ctrl.white = 15 ; /* 白色は 15 番 */
- ctrl.black = 8 ; /* 黒色は 0 番 */
- ctrl.gray = 7 ; /* 灰色は 7 番 */
- ctrl.xor = 7 ; /* 反転色は 7 番 */
-
- extern int APL_init() ;
-
- /* 初期化処理 */
- if (MMI_Open( &ctrl ) == NOERR)
- {
- /* 初期化に成功すればメインループに入る. */
- if (APL_init( argc, argv ) == NOERR)
- {
- /* 動作メモリのチェック */
- if(TL_checkMemory(1) * 4096 < MinMem)
- {
- /* alertMemFunc関数の追い越し禁止 */
- alertMemFlag = TRUE ;
-
- /* メモリ不足のアラート表示 */
- alertMemFunc() ;
- }
-
- MMI_ExecSystem() ;
- }
- }
-
- /* 終了処理 */
- MMI_Close() ;
-
- }
-
- int APL_init( argc, argv )
-
- int argc ;
- char *argv[] ;
- {
- extern MMIINIT initDataMWINDOW ;
-
- register int ret ;
-
- extern void setPointFunc() ;
- extern int windowId ;
-
- char tmenuPaletteWork[ 1536 ] ;
-
- /* ハイパ型部品の初期化 */
- if ((ret = MMI_initHyper()) < 0)
- return ret ;
- /* ダイアログ型部品の初期化 */
- if ((ret = MMI_initDialogL40()) < 0)
- return ret ;
- /* ウインドウ型部品の初期化 */
- if ((ret = MMI_initWindowL40()) < 0)
- return ret ;
- /* メッセージ型部品の初期化 */
- if ((ret = MMI_initMessageL40()) < 0)
- return ret ;
- /* ボタン型部品の初期化 */
- if ((ret = MMI_initButtonL40()) < 0)
- return ret ;
- /* アイコンボタン型部品の初期化 */
- if ((ret = MMI_initIconL40()) < 0)
- return ret ;
-
- /* 背景データの初期化 */
-
- /* データの登録 */
- if ((ret = MMI_Init(&initDataMWINDOW)) < 0)
- return ret ;
-
- /* TownsMENUのメュー色の設定 */
- EGB_tmenuPalette2( tmenuPaletteWork ) ;
-
- /* windowId(window型部品)を実行可能状態にする */
- MMI_SendMessage( windowId, MM_WAKE, 0 ) ;
-
- /* イベントが何も無いときに実行する関数の登録 */
- MMI_SetIdleTaskFunc( setPointFunc ) ;
-
- /* パラメータのよる座標の変更 */
- initPoint( argc, argv ) ;
-
- /* 背景を表示する */
- MMI_SendMessage(MMI_GetBaseObj(), MM_SHOW, 0) ;
-
- MMI_SendMessage(MMI_GetBaseObj(), MM_SETEXEC, 1, userFunc);
- MMI_CallMessage(MMI_GetApliId(), GM_TITLE, (int)"Point", 0);
-
- return NOERR ;
- }
-
- int initPoint( argc, argv )
-
- int argc ;
- char *argv[] ;
- {
- extern int windowId ;
-
- HYPER hyp ;
-
- int x ;
- int y ;
- int h ;
- int w ;
-
- int hmin = 52 ; /* Window型部品の最小の高さ */
- int hmax = 480 ; /* Window型部品の最大の高さ */
-
- int wmin = 81 ; /* Window型部品の最小の幅 */
- int wmax = 640 ; /* Window型部品の最大の幅 */
-
- int dx ;
- int dy ;
-
- MMI_SendMessage( windowId, MM_GETHYPER, 1, &hyp ) ;
-
- if(( argv[1] != NULL )&&( argv[2] != NULL )&&( argv[3] != NULL )&&( argv[4] != NULL ))
- {
- x = atoi( argv[1] ) ;
- y = atoi( argv[2] ) ;
- w = atoi( argv[3] ) ;
- h = atoi( argv[4] ) ;
-
- /* パラメータのチェック */
- if( h < hmin ) h = hmin ;
- if( h > hmax ) h = hmax ;
-
- if( w < wmin ) w = wmin ;
- if( w > wmax ) w = wmax ;
-
- if( x < 0 ) x = 0 ; /* 解像度のチェック(マニュアルを見るの) */
- if( x > 1024 ) x = 1024 - w ; /* が面倒くさいので。 */
-
- if( y < 22 ) y = 22 ;
- if( y + h > 768 ) y = 768 - h ;
-
- dx = hyp.fr.lupx - x ; /* 移動幅の計算 */
- dy = hyp.fr.lupy - y ; /* 移動幅の計算 */
-
- MMI_SendMessage( windowId, MM_MOVE, 2, -dx, -dy ) ;
-
- resizeWindowFunc( h, w ) ;
- }
-
- return NOERR ;
- }
-
- int resizeWindowFunc( h, w )
-
- int h ;
- int w ;
- {
- extern int windowId ;
- extern int xPointMessageId ;
- extern int yPointMessageId ;
- extern int xMessageId ;
- extern int yMessageId ;
-
- HYPER whyp ;
- HYPER xhyp ;
-
- int mx = 32 ; /* 座標数字のメッセージ型部品の横幅 */
- int px = 16 ; /* 座標文字のメッセージ型部品の横幅 */
- int hy = 16 ; /* 座標数字のメッセージ型部品&座標文字のメッセージ型部品の縦の幅 */
- int wh = 17 ; /* window型部品のタイトルバーの縦幅 */
- int sd = 3 ; /* window型部品の影の縦幅 */
-
- int spx ; /* メッセージ型部品の基本x座標 */
- int spy ; /* メッセージ型部品の基本y座標 */
-
- /* windowの幅の調整 */
- MMI_SendMessage( windowId, MM_GETHYPER, 1, &whyp ) ;
-
- whyp.fr.rdwx = whyp.fr.lupx + w ;
- whyp.fr.rdwy = whyp.fr.lupy + h ;
-
- MMI_SendMessage( windowId, MM_SETHYPER, 1, &whyp ) ;
-
-
- spx = whyp.fr.lupx + ( w-mx-px )/2 ;
- spy = whyp.fr.lupy + ( h-sd-wh-hy*2 )/2 + wh ;
-
- /* 幅の調整のよるx座標表示数字のメッセージ型部品の座標の調整 */
- MMI_SendMessage( xMessageId, MM_GETHYPER, 1, &xhyp ) ;
-
- xhyp.fr.lupx = spx + px ;
- xhyp.fr.lupy = spy ;
- xhyp.fr.rdwx = xhyp.fr.lupx + mx ;
- xhyp.fr.rdwy = xhyp.fr.lupy + hy ;
-
- MMI_SendMessage( xMessageId, MM_SETHYPER, 1, &xhyp ) ;
-
-
- /* 幅の調整のよるy座標表示数字のメッセージ型部品の座標の調整 */
- MMI_SendMessage( yMessageId, MM_GETHYPER, 1, &xhyp ) ;
-
- xhyp.fr.lupx = spx + px ;
- xhyp.fr.lupy = spy + hy ;
- xhyp.fr.rdwx = xhyp.fr.lupx + mx ;
- xhyp.fr.rdwy = xhyp.fr.lupy + hy ;
-
- MMI_SendMessage( yMessageId, MM_SETHYPER, 1, &xhyp ) ;
-
-
- /* 幅の調整のよる「x:」のメッセージ型部品の座標の調整 */
- MMI_SendMessage( xPointMessageId, MM_GETHYPER, 1, &xhyp ) ;
-
- xhyp.fr.lupx = spx ;
- xhyp.fr.lupy = spy ;
- xhyp.fr.rdwx = xhyp.fr.lupx + px ;
- xhyp.fr.rdwy = xhyp.fr.lupy + hy ;
-
- MMI_SendMessage( xPointMessageId, MM_SETHYPER, 1, &xhyp ) ;
-
-
- /* 幅の調整のよる「y:」のメッセージ型部品の座標の調整 */
- MMI_SendMessage( yPointMessageId, MM_GETHYPER, 1, &xhyp ) ;
-
- xhyp.fr.lupx = spx ;
- xhyp.fr.lupy = spy + hy ;
- xhyp.fr.rdwx = xhyp.fr.lupx + px ;
- xhyp.fr.rdwy = xhyp.fr.lupy + hy ;
-
- MMI_SendMessage( yPointMessageId, MM_SETHYPER, 1, &xhyp ) ;
-
- return NOERR ;
- }